﻿Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Data
Imports System.Windows.Forms
Imports DevComponents.DotNetBar.Controls
Imports DevComponents.Editors.DateTimeAdv
Imports DoAnQuanLyBanHang1065043_1065007.DoAnQuanLyBanHang.DTO
Imports DoAnQuanLyBanHang1065043_1065007.DoAnQuanLyBanHang.General
Imports DoAnQuanLyBanHang1065043_1065007.DoAnQuanLyBanHang.BUSS

Namespace DoAnQuanLyBanHang.DAO
    Public Class TonKhoCtrl
        Private m_TonKhoData As New TonKhoData()
        Private m_TonKhoInfo As New TonKhoInfo()

        Public Sub HienThiComboBox(cbx As ComboBox)
            Dim m_DT As DataTable = m_TonKhoData.LayTonKho()
            cbx.DataSource = m_DT
            cbx.DisplayMember = "Tháng"
            cbx.ValueMember = "Tháng"
        End Sub
        Public Sub HienThiComboBox1(cbx As ComboBox)
            Dim m_DT As DataTable = m_TonKhoData.LayTonKho()
            cbx.DataSource = m_DT
            cbx.DisplayMember = "Năm"
            cbx.ValueMember = "Năm"
        End Sub

        Public Shared Function LayDsTonKhoTheoThang(thang As Integer, nam As Integer) As IList(Of TonKhoInfo)
            Dim ds As IList(Of TonKhoInfo) = New List(Of TonKhoInfo)()

            Dim data As New TonKhoData()
            Dim tbl As DataTable = data.LayDSTonKhoTheoThang(thang, nam)

            Dim TonKho As IList(Of TonKhoInfo) = New List(Of TonKhoInfo)()

            For Each row As DataRow In tbl.Rows
                Dim TK As New TonKhoInfo()

                Dim m_MH As New MatHangInfo()
                m_MH.TenMH = Convert.ToString(row("Tên Mặt Hàng"))
                m_MH.MaMH = Convert.ToString(row("Mã Mặt Hàng"))
                TK.Tháng = Convert.ToInt32(row("Tháng"))
                TK.Năm = Convert.ToInt32(row("Năm"))
                TK.Tồn_Kho = Convert.ToInt64(row("Tồn Kho"))
                TK.Mã_Mặt_Hàng = Convert.ToString(row("Mã Mặt Hàng"))
                TK.Tên_Mặt_Hàng = Convert.ToString(row("Tên Mặt Hàng"))
                TK.MaMH = m_MH
                TonKho.Add(TK)
            Next
            Return TonKho
        End Function
    End Class
End Namespace
